<?php
/**
 * Created by JetBrains PhpStorm.
 * User: shaoshuai
 * Date: 11-10-3
 * Time: PM3:49
 */
include_once 'paperblog.php';
checkLogin();
$tags = getTags();
$settings = getSettings();
?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>TAG管理</title>
    <link href="resources/css/common.css" rel="stylesheet" />
    <style>
        form {
            border-bottom: 1px dotted #999;
            padding: 3px;
            margin: 0;
        }
        form span {
            display: inline-block;
            width: 100px;
        }
        form span:first-child {
            width: 80px;
        }
        form span:nth-child(3) {
            width: 150px;
        }
        form input[type=text] {
            width: 90px;
        }

        body > div:first-of-type {
            line-height: 2em;
        }
    </style>
</head>
<body>
    <div>博客地址：<?php echo $settings['base'] ?></div>
    <?php foreach ($tags as $tagName => $tag) { ?>
    <form action="action/tag.action.php" method="POST">
        <div>
            <span><?php echo $tagName ?><input type="hidden" name="id" value="<?php echo $tagName ?>" /></span>
            <span><input type="text" name="name" value="<?php echo $tagName ?>" /></span>
            <span>
                <select>
                    <option>这是所有此TAG的文章</option>
                    <?php
                    foreach ($tag['posts'] as $post) {
                    ?>
                    <option><?php echo $post ?></option>
                    <?php
                    }
                    ?>
                </select>
            </span>
            <span><input type="submit" name="action" value="保存" /><input type="submit" name="action" value="删除" /></span>
        </div>
    </form>
    <?php } ?>
    <form action="action/tag.action.php" method="POST">
        <div>
            <span>添加TAG</span>
            <span><input type="text" name="name" value="" /></span>
            <span></span>
            <span><input type="submit" name="action" value="添加" /></span>
        </div>
    </form>
    <div style="padding: 10px;">
        <a href="index.php">返回管理主页</a>
    </div>
</body>
</html>
